package com.example.perplonews.a_d_fragment.a_news.adapter

import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.example.perplonews.R
import com.example.perplonews.a_b_entity.ImageBannerEntity
import com.example.perplonews.a_b_entity.NewsEntity
import com.example.perplonews.a_b_entity.TextBannerEntity
import com.youth.banner.adapter.BannerAdapter
import com.youth.banner.util.BannerUtils

class ImageBannerAdapter : BannerAdapter<NewsEntity.Values, ImageBannerAdapter.TextBannerHolder> {
    constructor(list: ArrayList<NewsEntity.Values> ) : super(list) {

    }

    override fun onCreateHolder(parent: ViewGroup, viewType: Int): TextBannerHolder {
        return TextBannerHolder(BannerUtils.getView(parent,R.layout.item_news_image))
    }

    override fun onBindView(
        holder: TextBannerHolder,
        data: NewsEntity.Values,
        position: Int,
        size: Int
    ) {

//        if (data == null){
//
//            Glide.with(holder.itemView.context).load("https://i02piccdn.sogoucdn.com/367da58fe13055a5").into(holder.imageview)
//        }else{


            Glide.with(holder.itemView.context).load("https://i02piccdn.sogoucdn.com/0de8dcfc26ef408f").into(holder.imageview)
//        }
    }

    class TextBannerHolder : RecyclerView.ViewHolder {
        var imageview: ImageView?= null

        constructor(itemView: View) : super(itemView) {
            imageview = itemView.findViewById(R.id.banner_img)
        }

    }
}